<%-- 
    Document   : add_my_cart
    Created on : Mar 16, 2012, 11:11:10 AM
    Author     : mrson
--%>

<%@page import="BLL.BCart"%>
<%@page import="DTO.Cart"%>
<%@page import="DTO.User"%>
<%@page import="BLL.BUser"%>
<%@page import="BLL.BProduct"%>
<%@page import="DTO.Product"%>
<%@page import="java.util.ArrayList"%>
<%@page  pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
    </head>
    <%
     String userString = (String)session.getAttribute("username");
      DTO.User user = new BUser().getByUsername(userString);
      BProduct bp = new BProduct();
      BUser bu = new BUser();
    
    
    
    


%>
    <body>
        <table width="100%" height="30">
            <tr>
                <td>
                    <p><b>Hướng dẫn:</b> Để xóa sản phẩm khỏi giỏ hàng, click Xóa bỏ / Điền số lượng sản phẩm vào ô rồi click Cập nhật để thêm số lượng</p>
                </td>
            </tr>
        </table>
        
        <table width="100%">
            <tr>
                <td>
                    <table width="100%" border="1">
                   
                    <input name="op" value="" type="hidden">
                    <tbody><tr>
                    <td class="title td">Số lượng</td>
                    <td class="title td">Tên sản phẩm</td>
                    <td class="title td">Giá</td>
                    <td class="title td">&nbsp;</td>
                    </tr>
                    <%
                    ArrayList<Cart> carts = new BCart().getByUserId(1);
                    if(carts != null)
                                               {
                    for(Cart c : carts)
                                               {
                    %>
                    <tr>
                    <td align="center">
                    <form name="frmcart" action="servlet" method="post">
                    <input name="add_my_cart_update" type="hidden">
                    <input name="buy_number" size="15" style="text-align: center;" type="text">
                    <div style="padding-top:5px"><input value="Cập nhật" type="submit"></div>
                    </td></form>
                    <td class="td">
                    
                    <div class="title"><a href="#" class="title">
                            
                            <%
                            
                            bp.getById(c.getProductId()).getName();
                            %>
                        
                        </a></div></td>
                    <td class="td">
                        <%
                        bp.getById(1).getPrice();
                        %>        
                    </td>
                    <form name="frmcart" action="servlet" method="post">
                    <input name="add_my_cart_delete" type="hidden">
                    <td class="td"><input value="Xóa bỏ" type="submit"></td></form>
                    </tr>
                    <%
                    }
                                       }
                    %>
                    
                    <tr>
                    <td></td>
                    <td style="padding-right: 10px;" class="td" align="right"><strong>Tổng cộng: </strong></td>
                    <td style="padding-left: 10px;">
                        <%
                        
                        String tong = (String) request.getAttribute("tong");
                        if(tong==null) tong="3";
                        int s = Integer.parseInt(tong);
                        String pr=null;
                        //pr=priceProduct.getPrice();
                        if(pr==null) pr="4";
                        int price = Integer.parseInt(pr);
                        s=s*price;
                        out.print(s+" VND");
                        %>
                        
                    </td>
                    <form name="frmcart" action="servlet" method="post">
                    <input name="add_my_cart_continus" type="hidden">
                    <td class="td"><input value="Tiếp tục mua" type="submit"></td></form>
                    </tr>
                    </tbody></table>
                    
                </td>
            </tr>
        </table>
        
        <table class="content" cellpadding="5" cellspacing="2" width="100%">
            <tbody><tr>
            <td colspan="2" class="title" bgcolor="#CCCCCC">Thông tin thanh toán</td>
            </tr>
            <tr>
            <td></td>
            <td style="color: rgb(255, 0, 0);">" Du lieu nguoi dung"</td>
            </tr>
            <tr>
            <td class="title" colspan="2" style="padding-left: 20px;" nowrap="nowrap" align="left">THÔNG TIN NGƯỜI ĐẶT HÀNG  :</td>
            </tr>
            <tr>
            <td nowrap="nowrap" align="right">Họ và Tên  :</td>
            <td>
                <%=user.getUsername()%>
            </td>
            </tr>
            <tr>
            <td nowrap="nowrap" align="right">Địa chỉ  :</td>
            <td class="form_asterisk" nowrap="nowrap">
                <%=user.getAddress()%>
            </td>
            </tr>
            <tr>
            <td nowrap="nowrap" align="right">E-mail :</td>
            <td class="form_asterisk">
                <%=user.getEmail()%>
            </td>
            </tr>
            <tr>
            <td nowrap="nowrap" align="right">Điện thoại  :</td>
            <td class="form_asterisk">
                <%=user.getNumberPhone()%>
            </td>
            </tr>
          
            <tr>
                <td>&nbsp;</td>
                <td>
                    <input type="submit" value="Đặt hàng"/> 
                </td>
            </tr>

            </tbody>
        </table>
    </body>
</html>
